set.seed(1)
dyn.load("test/PF.so")
M<-200
T<-150
theta<-c(0.95,0.05,0.01,0.1)

Y<-matrix(nrow=T)
X<-matrix(nrow=T)
X[1]<-rnorm(1,m=0,sd=sqrt(theta[2]/(1-theta[1]**2)))
Y[1]<-rnorm(1,m=theta[3],sd=sqrt(theta[4]*exp(X[1])))
for(t in 2:T)
{
	X[t]<-rnorm(1,m=theta[1]*X[t-1],sd=sqrt(theta[2]))
	Y[t]<-rnorm(1,m=theta[3],sd=sqrt(theta[4]*exp(X[t])))
}


ft<-function(theta)
{
X<-matrix(0,nrow=T,ncol=1)
t=proc.time()
res1<-.C("IBIS", as.integer(M),as.integer(T),as.integer(1),as.double(Y),as.double(X),as.double(theta),as.integer(4),res=as.double(matrix(0,nrow=T)))
cat("\n");cat("time: ")
return(res1$res)
}
theta<-c(0.95,0.05,0.01,0.1)
res<-ft(theta)
res<-ft(theta)
plot(exp(X),type="l")
lines(exp(res),col="red")
